package com.example.license.service.impl;

import com.example.license.entity.LicenseConstant;
import com.example.license.service.IAbstractServerInfos;

import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author YangJian
 * @description: 用于获取客户Linux服务器的基本信息
 * @date 2022/4/5 16:34
 */
public class LinuxServiceImpl extends IAbstractServerInfos {

	@Override
	public List<String> getIpAddress() throws Exception {
		List<String> result = new ArrayList<>();
		//获取所有网络接口
		List<InetAddress> inetAddresses = getLocalAllInetAddress();
		if (inetAddresses != null && inetAddresses.size() > 0) {
			result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
		}
		return result;
	}

	@Override
	public List<String> getMacAddress() throws Exception {
		return getLinuxMacInfo(LicenseConstant.LINUX_CONMMAND);
	}
}
